package com.controller;

import com.entity.Cashier;
import com.entity.Prescriptiondetail;
import com.entity.Result;
import com.service.CashierService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@SuppressWarnings({"all"})
@RestController
@CrossOrigin(origins = "*")
@RequestMapping("/cashier")
public class CashierController {

    @Resource
    private CashierService cashierService;

    @PostMapping("/login")
    public Result login(Cashier cashier){
        System.out.println("进入login控制器："+cashier);
        try {
            return Result.success(cashierService.login_cashier(cashier));
        } catch (Exception e) {
            return Result.error("login控制器报错");
        }
    }

    @PostMapping("/liquidation")
    public Result liquidation(){
        System.out.println("进入liquidation控制器");
        try {
            return Result.success(cashierService.liquidation());
        } catch (Exception e) {
            return Result.error("liquidation控制器报错");
        }
    }

    @PostMapping("/updateP")
    public Result updateP(Prescriptiondetail prescriptiondetail){
        System.out.println("进入updateP控制器:"+prescriptiondetail);
        try {
            cashierService.updateP(prescriptiondetail);
            return Result.success("更新成功");
        } catch (Exception e) {
            return Result.error("updateP控制器报错");
        }
    }

    @PostMapping("/getDaily")
    public Result getList(Prescriptiondetail prescriptiondetail){
        System.out.println("进入getList控制器:"+prescriptiondetail);
        try {
            return Result.success(cashierService.getDaily(prescriptiondetail));
        } catch (Exception e) {
            return Result.error("getList控制器报错");
        }
    }

    @PostMapping("/getDailyDrug")
    public Result getDailyDrug(Prescriptiondetail prescriptiondetail){
        System.out.println("进入getDailyDrug控制器:"+prescriptiondetail);
        try {
            return Result.success(cashierService.getDailyDrug(prescriptiondetail));
        } catch (Exception e) {
            return Result.error("getDailyDrug控制器报错");
        }
    }
}
